<?php
/*------------------------------------------------------------------------
# company - company management
# @author    pipapai.com
-------------------------------------------------------------------------*/

defined('_JEXEC') or die;
// disable core styles to avoid bs conflict
OC_Util::$core_styles = array();

if(isDevMode()) {
   OCP\Util::addStyle('company', 'company');
   OCP\Util::addScript('company', 'home');
   OCP\Util::addScript('company', 'syncinfo');
   OCP\Util::addScript('company', 'autoactions');
} else {
   OCP\Util::addStyle('static', 'company');
   OCP\Util::addScript('static', 'apps/company.home.min');
   OCP\Util::addScript('static', 'apps/company.syncinfo.min');
   OCP\Util::addScript('static', 'apps/company.autoactions.min');
}

OCP\App::setActiveNavigationEntry('company_settings');

$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");

$thirdaccounts_info = $_['thirdaccounts_info'];
$thirdaccounts_status = $_['thirdaccounts_status'];
$thirdaccount_51job = empty($thirdaccounts_info['51job']) ? null : $thirdaccounts_info['51job']; 
$thirdaccount_zhilian = empty($thirdaccounts_info['zhilian']) ? null : $thirdaccounts_info['zhilian']; 
$thirdaccount_jiancai = empty($thirdaccounts_info['jiancai']) ? null : $thirdaccounts_info['jiancai'];
$thirdaccount_lagou = empty($thirdaccounts_info['lagou']) ? null : $thirdaccounts_info['lagou'];
$thirdaccount_status_51job = empty($thirdaccounts_status['51job']['fetchjobs']) ? null : $thirdaccounts_status['51job']['fetchjobs']; 
$thirdaccount_status_zhilian = empty($thirdaccounts_status['zhilian']['fetchjobs']) ? null : $thirdaccounts_status['zhilian']['fetchjobs'];
$thirdaccount_status_jiancai = empty($thirdaccounts_status['jiancai']['fetchjobs']) ? null : $thirdaccounts_status['jiancai']['fetchjobs'];
$thirdaccount_status_lagou = empty($thirdaccounts_status['lagou']['fetchjobs']) ? null : $thirdaccounts_status['lagou']['fetchjobs'];

//check login status: 1.password  2.result != error 3.result != captcha
$login_status_51job  = (!empty($thirdaccount_51job['password']) && (isset($thirdaccounts_status['51job']['result']) && $thirdaccounts_status['51job']['result'] != 'error' && $thirdaccounts_status['51job']['result'] != 'captcha')) ? 1: 0;
$login_status_zhilian  = (!empty($thirdaccount_zhilian['password']) && (isset($thirdaccounts_status['zhilian']['result']) && $thirdaccounts_status['zhilian']['result'] != 'error' && $thirdaccounts_status['zhilian']['result'] != 'captcha')) ? 1: 0;
$login_status_jiancai  = (!empty($thirdaccount_jiancai['password']) && (isset($thirdaccounts_status['jiancai']['result']) && $thirdaccounts_status['jiancai']['result'] != 'error' && $thirdaccounts_status['jiancai']['result'] != 'captcha')) ? 1: 0;
$login_status_lagou  = (!empty($thirdaccount_lagou['password']) && (isset($thirdaccounts_status['lagou']['result']) && $thirdaccounts_status['lagou']['result'] != 'error' && $thirdaccounts_status['lagou']['result'] != 'captcha')) ? 1: 0;

$autofetchjobs_info_51job = !isset($thirdaccounts_status['51job']['autofetchjobs']) ? null : $thirdaccounts_status['51job']['autofetchjobs'];
$autofetchjobs_info_zhilian = !isset($thirdaccounts_status['zhilian']['autofetchjobs']) ? null : $thirdaccounts_status['zhilian']['autofetchjobs'];
$autofetchjobs_info_jiancai = !isset($thirdaccounts_status['jiancai']['autofetchjobs']) ? null : $thirdaccounts_status['jiancai']['autofetchjobs'];
$autofetchjobs_info_lagou = !isset($thirdaccounts_status['lagou']['autofetchjobs']) ? null : $thirdaccounts_status['lagou']['autofetchjobs'];

$autofetchjobs_on_51job = ($autofetchjobs_info_51job === null || (isset($autofetchjobs_info_51job['disabled']) && $autofetchjobs_info_51job['disabled'] == 1))? 0 : 1;
$autofetchjobs_on_zhilian = ($autofetchjobs_info_zhilian === null || (isset($autofetchjobs_info_zhilian['disabled']) && $autofetchjobs_info_zhilian['disabled'] == 1) || (isset($autofetchjobs_info_zhilian['result']) && $autofetchjobs_info_zhilian['result'] == 'captcha'))? 0 : 1;
$autofetchjobs_on_jiancai = ($autofetchjobs_info_jiancai === null || (isset($autofetchjobs_info_jiancai['disabled']) && $autofetchjobs_info_jiancai['disabled'] == 1))? 0 : 1;
$autofetchjobs_on_lagou = ($autofetchjobs_info_lagou === null || (isset($autofetchjobs_info_lagou['disabled']) && $autofetchjobs_info_lagou['disabled'] == 1))? 0 : 1;

$autorenewjobs_info_51job = !isset($thirdaccounts_status['51job']['autorenewjobs']) ? null : $thirdaccounts_status['51job']['autorenewjobs'];
$autorenewjobs_info_zhilian = !isset($thirdaccounts_status['zhilian']['autorenewjobs']) ? null : $thirdaccounts_status['zhilian']['autorenewjobs'];
$autorenewjobs_info_jiancai = !isset($thirdaccounts_status['jiancai']['autorenewjobs']) ? null : $thirdaccounts_status['jiancai']['autorenewjobs'];
$autorenewjobs_info_lagou = !isset($thirdaccounts_status['lagou']['autorenewjobs']) ? null : $thirdaccounts_status['lagou']['autorenewjobs'];

$autorenewfolderid_51job = empty($_['autorenewfolderid_51job']) ? null : $_['autorenewfolderid_51job'];
$autorenewfolderid_zhilian = empty($_['autorenewfolderid_zhilian']) ? null : $_['autorenewfolderid_zhilian'];
$autorenewfolderid_jiancai = empty($_['autorenewfolderid_jiancai']) ? null : $_['autorenewfolderid_jiancai'];
$autorenewfolderid_lagou = empty($_['autorenewfolderid_lagou']) ? null : $_['autorenewfolderid_lagou'];


$subuser = PCompanyHelper::getSubUser();
$user = $_['user'];
$hasPermission = $_['masteruser'] || ($subuser->permissions & PERMISSION_JOB_CRUD && $subuser->permissions & PERMISSION_JOB_ADMIN_ALL);

$check_syncstatus_51job = PCompanyHelper::getAutoActionsStatus(empty($thirdaccount_51job['password'])?null:$thirdaccount_51job['password'],empty($thirdaccounts_status['51job'])?null:$thirdaccounts_status['51job']);
$check_syncstatus_zhilian = PCompanyHelper::getAutoActionsStatus(empty($thirdaccount_zhilian['password'])?null:$thirdaccount_zhilian['password'],empty($thirdaccounts_status['zhilian'])?null:$thirdaccounts_status['zhilian']);
$check_syncstatus_jiancai = PCompanyHelper::getAutoActionsStatus(empty($thirdaccount_jiancai['password'])?null:$thirdaccount_jiancai['password'],empty($thirdaccounts_status['jiancai'])?null:$thirdaccounts_status['jiancai']);
$check_syncstatus_lagou = PCompanyHelper::getAutoActionsStatus(empty($thirdaccount_lagou['password'])?null:$thirdaccount_lagou['password'],empty($thirdaccounts_status['lagou'])?null:$thirdaccounts_status['lagou']);
?>

<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('company/js', 'company.php'));?>"></script>

<div class="hr_inner_navigate clearfix">
   <ul class="clearfix">
      <?php PCompanyHelper::showNavigationMenu($_['masteruser'], 'synchronousinfo');?>
   </ul>
</div>

<div class="hr_company_set" style="padding:20px 0 30px 0;">
   <div class="synch_firsttip">同步第三方招聘网站信息，让您一站式管理所有职位、简历。</div>
   <div class="configemail_self configemail_margin medium">或手动配置转发邮箱 <a><?php echo $_['resumeforwardemail']?></a> 接收简历 <a class="howtoaccept medium" href="javascript:;">如何配置？</a></div>
   <div class="synch_tablelist">
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
         <tr>
           <th width="15%" align="left" style="padding-left:33px;">第三方网站</th>
           <th width="20%">账号信息</th>
           <th width="23%"><?php if($hasPermission):?>手动同步<?php endif; ?></th>
           <?php if($_['masteruser']):?>
           <th width="17%" align="left">自动同步</th>
           <th width="25%" align="left">自动刷新</th>
           <?php endif; ?>
         </tr>
         <tr bgcolor="#f9fafb">
            <td><div class="synchronous_info"><i class="config_51"></i>&nbsp;前程无忧</div></td>
            <td class="medium" align="center">
               <span class="yellowcolor medium"><?php echo empty($thirdaccount_51job) ? '未保存账号' : $thirdaccount_51job['membername'] ?></span>
               <a href="#" class="changeaccount" rel="51job_accountchange"><?php echo empty($thirdaccount_51job) ? '设置账号' : '修改账号' ?></a>
            </td>
            <td align="center">
            <?php if($hasPermission):?>
            <?php if(empty($thirdaccount_status_51job) || $thirdaccount_status_51job['result'] != 'syncing'): ?>
            <?php 
               list($sync_51job_title, $sync_51job_iclass) = PCompanyHelper::getSyncStatus('fetchjobs', $thirdaccount_status_51job,true);
             ?>
               <a href="#accountsetdialog_51job" class="ppp_bluebtn btn_click" data-type='51job' data-syncaction='fetchjobs' data-autofetchon="<?=$autofetchjobs_on_51job ?>" data-vid="<?=$_['masteruser']?$user->vid:0 ?>" id='sync_click_51job'>同步职位</a>
               <i title="<?=$sync_51job_iclass ? $sync_51job_title : '尚未同步'?>" class="syc_iconsown <?=$sync_51job_iclass ? $sync_51job_iclass : 'syc_iconsown_gray'?>"></i>
            <?php else: ?>
               <span style="margin-left:-15px;" class="ppp_whitebtn btn_success">同步中...</span>
            <?php endif; ?>
            <?php endif; ?>
            </td>

            <?php if($_['masteruser']):?>
            <td id="autofetchjobs_result_51job" data-loginstatus="<?=$login_status_51job ?>" data-synctype="51job" data-syncaction="autofetchjobs">
            <?php if($hasPermission):?>
            <?php if(!($autofetchjobs_info_51job === NULL) && $check_syncstatus_51job):?> 
                <?php if(!isset($autofetchjobs_info_51job['disabled']) || $autofetchjobs_info_51job['disabled'] == 1):?>
                   <span  class="hdbtn hdbtn_notok" title="点击开启自动同步"></span>
                   <i class="syc_iconsown syc_iconsown_gray"></i>
                <?php else: ?>
                   <span class="hdbtn hdbtn_ok"></span>
                   <?php if(isset($autofetchjobs_info_51job['result'])):?>
                      <?php if($autofetchjobs_info_51job['result'] == 'success'): ?>
                      <i class="syc_iconsown syc_iconsown_success" title="<?php echo JHtml::_('date', $autofetchjobs_info_51job['time'], 'Y-m-d H:i:s') .' '. (empty($autofetchjobs_info_51job['msg'])?'同步成功！':$autofetchjobs_info_51job['msg']); ?>"></i>
                      <?php elseif($autofetchjobs_info_51job['result'] == 'syncing'): ?>
                      <i class="syc_iconsown syc_iconsown_gray" title="自动同步中"></i>
                      <?php elseif($autofetchjobs_info_51job['result'] == 'error'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="<?=$autofetchjobs_info_51job['msg'] ?>"></i>
                      <?php elseif($autofetchjobs_info_51job['result'] == 'captcha'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="登录验证码失败！"></i>
                      <?php endif; ?>
                   <?php else:?>
                    <i class="syc_iconsown syc_iconsown_gray"></i>
                   <?php endif;?>
                <?php endif; ?>
            <?php else: ?>
               <span  class="hdbtn hdbtn_notok" title="点击开启自动同步"></span>
               <i class="syc_iconsown syc_iconsown_gray"></i>
            <?php endif; ?>
            <?php endif; ?>
            </td>
            <td id="autorenewjobs_result_51job" data-loginstatus="<?=$login_status_51job ?>" data-synctype="51job" data-syncaction="autorenewjobs">
            <?php if($hasPermission):?>
            <?php if(!($autorenewjobs_info_51job === NULL)  && $check_syncstatus_51job):?> 
                <?php if(!isset($autorenewjobs_info_51job['disabled']) || $autorenewjobs_info_51job['disabled'] == 1):?>
                   <span  class="hdbtn hdbtn_notok" title="点击开启自动刷新"></span>
                   <i class="syc_iconsown syc_iconsown_gray"></i>
                <?php else: ?>
                   <span class="hdbtn hdbtn_ok"></span>
                   <?php if(isset($autorenewjobs_info_51job['result'])):?>
                      <?php if($autorenewjobs_info_51job['result'] == 'success'): ?>
                      <i class="syc_iconsown syc_iconsown_success" title="<?php echo JHtml::_('date', $autorenewjobs_info_51job['time'], 'Y-m-d H:i:s') .' '. (empty($autorenewjobs_info_51job['msg'])?'刷新成功！':$autorenewjobs_info_51job['msg']); ?>"></i>
                      <?php elseif($autorenewjobs_info_51job['result'] == 'syncing'): ?>
                      <i class="syc_iconsown syc_iconsown_gray" title="自动刷新中"></i>
                      <?php elseif($autorenewjobs_info_51job['result'] == 'error'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="<?=$autorenewjobs_info_51job['msg'] ?>"></i>
                      <?php elseif($autorenewjobs_info_51job['result'] == 'captcha'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="登录验证码失败！"></i>
                      <?php endif; ?>
                   <?php else:?>
                    <i class="syc_iconsown syc_iconsown_gray"></i>
                   <?php endif;?>
                <?php endif; ?>
            <?php else: ?>
               <span  class="hdbtn hdbtn_notok" title="点击开启自动刷新"></span>
               <i class="syc_iconsown syc_iconsown_gray"></i>
            <?php endif; ?>

            <?php 
               $selectjobtitle = "";
               if (!empty($autorenewfolderid_51job)) {
                  list($selectjobtitle,$curcityids,$curfolderid) = PCompanyHelper::getSelectJobTitle($autorenewfolderid_51job);
                  echo "<a id=\"selectjobtitle\" href=\"javascript:;\" class=\"ppp_whitebtn\">".$selectjobtitle."</a>";
               }
            ?>
            <?php endif; ?>
            </td>
            <?php endif; ?>
         </tr>
         <tr>
            <td><div class="synchronous_info"><i class="config_zhilian"></i>&nbsp;智联招聘</div></td>
            <td class="medium" align="center">
               <span class="yellowcolor medium"><?php echo empty($thirdaccount_zhilian['username']) ? '未保存账号' : $thirdaccount_zhilian['username'] ?></span>
               <a href="#" class="changeaccount" rel="zhilian_accountchange"><?php echo empty($thirdaccount_zhilian['username']) ? '设置账号' : '修改账号' ?></a>
            </td>
            <td align="center">
            <?php if($hasPermission):?>
            <?php if(empty($thirdaccount_status_zhilian) || $thirdaccount_status_zhilian['result'] != 'syncing'): ?>
            <?php 
               list($sync_zhilian_title, $sync_zhilian_iclass) = PCompanyHelper::getSyncStatus('fetchjobs', $thirdaccount_status_zhilian,true);
             ?>
               <a href="#accountsetdialog_zhilian" class="ppp_bluebtn btn_click" data-type='zhilian' data-syncaction='fetchjobs' data-autofetchon="<?=$autofetchjobs_on_zhilian ?>" data-vid="<?=$_['masteruser']?$user->vid:0  ?>" id='sync_click_zhilian'>同步职位</a>
               <i title="<?=$sync_zhilian_iclass ? $sync_zhilian_title : '尚未同步'?>" class="syc_iconsown <?=$sync_zhilian_iclass ? $sync_zhilian_iclass : 'syc_iconsown_gray'?>"></i>
            <?php else: ?>
               <span style="margin-left:-15px;" class="ppp_whitebtn btn_success">同步中...</span>
            <?php endif; ?>
            <?php endif; ?>
            </td>

            <?php if($_['masteruser']):?>
            <td id="autofetchjobs_result_zhilian" data-loginstatus="<?=$login_status_zhilian ?>" data-synctype="zhilian" data-syncaction="autofetchjobs">
            <?php if($hasPermission):?>
            <?php if(!($autofetchjobs_info_zhilian === NULL) && $check_syncstatus_zhilian):?> 
                <?php if(!isset($autofetchjobs_info_zhilian['disabled']) || $autofetchjobs_info_zhilian['disabled'] == 1):?>
                   <span  class="hdbtn hdbtn_notok" title="点击开启自动同步"></span>
                   <i class="syc_iconsown syc_iconsown_gray"></i>
                <?php else: ?>
                   <span class="hdbtn hdbtn_ok"></span>
                   <?php if(isset($autofetchjobs_info_zhilian['result'])):?>
                         <?php if($autofetchjobs_info_zhilian['result'] == 'success'): ?>
                         <i class="syc_iconsown syc_iconsown_success" title="<?php echo JHtml::_('date', $autofetchjobs_info_zhilian['time'], 'Y-m-d H:i:s') .' '. (empty($autofetchjobs_info_zhilian['msg'])?'同步成功！':$autofetchjobs_info_zhilian['msg']); ?>"></i>
                         <?php elseif($autofetchjobs_info_zhilian['result'] == 'syncing'): ?>
                         <i class="syc_iconsown syc_iconsown_gray" title="自动同步中"></i>
                         <?php elseif($autofetchjobs_info_zhilian['result'] == 'error'): ?>
                         <i class="syc_iconsown syc_iconsown_fail" title="<?=$autofetchjobs_info_zhilian['msg'] ?>"></i>
                         <?php elseif($autofetchjobs_info_zhilian['result'] == 'captcha'): ?>
                         <i class="syc_iconsown syc_iconsown_fail" title="登录验证码失败！"></i>
                         <?php endif; ?>
                    <?php else:?>
                    <i class="syc_iconsown syc_iconsown_gray"></i>  
                   <?php endif;?>
                <?php endif; ?>
            <?php else: ?>
               <span  class="hdbtn hdbtn_notok" title="点击开启自动同步"></span>
               <i class="syc_iconsown syc_iconsown_gray"></i>
            <?php endif; ?>
            <?php endif; ?>
            </td>

            <td id="autorenewjobs_result_zhilian" data-loginstatus="<?=$login_status_zhilian ?>" data-synctype="zhilian" data-syncaction="autorenewjobs">
              <?php if($hasPermission):?>
              <?php if(!($autorenewjobs_info_zhilian === NULL) && $check_syncstatus_zhilian):?> 
                <?php if(!isset($autorenewjobs_info_zhilian['disabled']) || $autorenewjobs_info_zhilian['disabled'] == 1):?>
                   <span  class="hdbtn hdbtn_notok" title="点击开启自动刷新"></span>
                   <i class="syc_iconsown syc_iconsown_gray"></i>
                <?php else: ?>
                   <span class="hdbtn hdbtn_ok"></span>
                   <?php if(isset($autorenewjobs_info_zhilian['result'])):?>
                      <?php if($autorenewjobs_info_zhilian['result'] == 'success'): ?>
                      <i class="syc_iconsown syc_iconsown_success" title="<?php echo JHtml::_('date', $autorenewjobs_info_zhilian['time'], 'Y-m-d H:i:s') .' '. (empty($autorenewjobs_info_zhilian['msg'])?'刷新成功！':$autorenewjobs_info_zhilian['msg']); ?>"></i>
                      <?php elseif($autorenewjobs_info_zhilian['result'] == 'syncing'): ?>
                      <i class="syc_iconsown syc_iconsown_gray" title="自动刷新中"></i>
                      <?php elseif($autorenewjobs_info_zhilian['result'] == 'error'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="<?=$autorenewjobs_info_zhilian['msg'] ?>"></i>
                      <?php elseif($autorenewjobs_info_zhilian['result'] == 'captcha'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="登录验证码失败！"></i>
                      <?php endif; ?>
                   <?php else:?>
                    <i class="syc_iconsown syc_iconsown_gray"></i>
                   <?php endif;?>
                <?php endif; ?>
            <?php else: ?>
               <span  class="hdbtn hdbtn_notok" title="点击开启自动刷新"></span>
               <i class="syc_iconsown syc_iconsown_gray"></i>
            <?php endif; ?>

             <?php 
                $selectjobtitle = "";
                if (!empty($autorenewfolderid_zhilian)) {
                   list($selectjobtitle,$curcityids,$curfolderid) = PCompanyHelper::getSelectJobTitle($autorenewfolderid_zhilian);
                   echo "<a id=\"selectjobtitle\" href=\"javascript:;\" class=\"ppp_whitebtn\">".$selectjobtitle."</a>";
                }
             ?>
             <?php endif; ?>
            </td>
            <?php endif;?>
         </tr>
         <tr bgcolor="#f9fafb">
            <td><div class="synchronous_info"><i class="config_lagou"></i>&nbsp;拉勾</div></td>
            <td class="medium" align="center">
               <span class="yellowcolor medium"><?php echo empty($thirdaccount_lagou) ? '未保存账号' : $thirdaccount_lagou['username'] ?></span>
               <a href="#" class="changeaccount" rel="lagou_accountchange"><?php echo empty($thirdaccount_lagou) ? '设置账号' : '修改账号' ?></a>
            </td>
            <td align="center">

            <?php if($hasPermission):?>
            <?php if(empty($thirdaccount_status_lagou) || $thirdaccount_status_lagou['result'] != 'syncing'): ?>
            <?php 
               list($sync_lagou_title, $sync_lagou_iclass) = PCompanyHelper::getSyncStatus('fetchjobs', $thirdaccount_status_lagou,true);
             ?>
               <a href="#accountsetdialog_lagou" class="ppp_bluebtn btn_click" data-type='lagou' data-syncaction='fetchjobs' data-autofetchon="<?=$autofetchjobs_on_lagou ?>" data-vid="<?=$user->vid ?>" id='sync_click_lagou'>同步职位</a>
               <i title="<?=$sync_lagou_iclass ? $sync_lagou_title : '尚未同步'?>" class="syc_iconsown <?=$sync_lagou_iclass ? $sync_lagou_iclass : 'syc_iconsown_gray'?>"></i>
            <?php else: ?>
               <span style="margin-left:-15px;" class="ppp_whitebtn btn_success">同步中...</span>
            <?php endif; ?>
            <?php endif; ?>
            </td>

            <?php if($_['masteruser']):?>
            <td id="autofetchjobs_result_lagou" data-loginstatus="<?=$login_status_lagou ?>" data-synctype="lagou" data-syncaction="autofetchjobs">
            <?php if($hasPermission):?>
             <?php if(!($autofetchjobs_info_lagou === NULL) && $check_syncstatus_lagou):?> 
                <?php if(!isset($autofetchjobs_info_lagou['disabled']) || $autofetchjobs_info_lagou['disabled'] == 1):?>
                   <span  class="hdbtn hdbtn_notok" title="点击开启自动同步"></span>
                   <i class="syc_iconsown syc_iconsown_gray"></i>
                <?php else: ?>
                   <span class="hdbtn hdbtn_ok"></span>
                   <?php if(isset($autofetchjobs_info_lagou['result'])):?>
                      <?php if($autofetchjobs_info_lagou['result'] == 'success'): ?>
                      <i class="syc_iconsown syc_iconsown_success" title="<?php echo JHtml::_('date', $autofetchjobs_info_lagou['time'], 'Y-m-d H:i:s') .' '. (empty($autofetchjobs_info_lagou['msg'])?'同步成功！':$autofetchjobs_info_lagou['msg']); ?>"></i>
                      <?php elseif($autofetchjobs_info_lagou['result'] == 'syncing'): ?>
                      <i class="syc_iconsown syc_iconsown_gray" title="自动同步中"></i>
                      <?php elseif($autofetchjobs_info_lagou['result'] == 'error'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="<?=$autofetchjobs_info_lagou['msg'] ?>"></i>
                      <?php elseif($autofetchjobs_info_lagou['result'] == 'captcha'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="登录验证码失败！"></i>
                      <?php endif;?>
                  <?php else: ?>
                    <i class="syc_iconsown syc_iconsown_gray"></i>
                  <?php endif?>
                <?php endif; ?>
            <?php else: ?>
               <span  class="hdbtn hdbtn_notok" title="点击开启自动同步"></span>
               <i class="syc_iconsown syc_iconsown_gray"></i>
            <?php endif; ?>
            <?php endif; ?>

            </td>

            <td id="autorenewjobs_result_lagou" data-loginstatus="<?=$login_status_lagou ?>" data-synctype="lagou" data-syncaction="autorenewjobs">
            <?php if($hasPermission):?>
              <?php if(!($autorenewjobs_info_lagou === NULL) && $check_syncstatus_lagou):?> 
                <?php if(!isset($autorenewjobs_info_lagou['disabled']) || $autorenewjobs_info_lagou['disabled'] == 1):?>
                   <span  class="hdbtn hdbtn_notok" title="点击开启自动刷新"></span>
                   <i class="syc_iconsown syc_iconsown_gray"></i>
                <?php else: ?>
                   <span class="hdbtn hdbtn_ok"></span>
                   <?php if(isset($autorenewjobs_info_lagou['result'])):?>
                      <?php if($autorenewjobs_info_lagou['result'] == 'success'): ?>
                      <i class="syc_iconsown syc_iconsown_success" title="<?php echo JHtml::_('date', $autorenewjobs_info_lagou['time'], 'Y-m-d H:i:s') .' '. (empty($autorenewjobs_info_lagou['msg'])?'刷新成功！':$autorenewjobs_info_lagou['msg']); ?>"></i>
                      <?php elseif($autorenewjobs_info_lagou['result'] == 'syncing'): ?>
                      <i class="syc_iconsown syc_iconsown_gray" title="自动刷新中"></i>
                      <?php elseif($autorenewjobs_info_lagou['result'] == 'error'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="<?=$autorenewjobs_info_lagou['msg'] ?>"></i>
                      <?php elseif($autorenewjobs_info_lagou['result'] == 'captcha'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="登录验证码失败！"></i>
                      <?php endif; ?>
                   <?php else:?>
                    <i class="syc_iconsown syc_iconsown_gray"></i>
                   <?php endif;?>
                <?php endif; ?>
            <?php else: ?>
               <span  class="hdbtn hdbtn_notok" title="点击开启自动刷新"></span>
               <i class="syc_iconsown syc_iconsown_gray"></i>
            <?php endif; ?>

            <?php 
               $selectjobtitle = "";
               if (!empty($autorenewfolderid_lagou)) {
                  list($selectjobtitle,$curcityids,$curfolderid) = PCompanyHelper::getSelectJobTitle($autorenewfolderid_lagou);
                  echo "<a id=\"selectjobtitle\" href=\"javascript:;\" class=\"ppp_whitebtn\">".$selectjobtitle."</a>";
               }
             ?>
             <?php endif; ?>
            </td>
            <?php endif; ?>
         </tr>
         <tr>
            <td><div class="synchronous_info"><i class="config_jianzhu"></i>&nbsp;建筑英才</div></td>
            <td class="medium" align="center">
               <span class="yellowcolor medium"><?php echo empty($thirdaccount_jiancai) ? '未保存账号' : $thirdaccount_jiancai['username'] ?></span>
               <a href="#" class="changeaccount" rel="jiancai_accountchange"><?php echo empty($thirdaccount_jiancai) ? '设置账号' : '修改账号' ?></a>
            </td>
            <td align="center">
            <?php if($hasPermission):?>
            <?php if(empty($thirdaccount_status_jiancai) || $thirdaccount_status_jiancai['result'] != 'syncing'): ?>
            <?php 
               list($sync_jiancai_title, $sync_jiancai_iclass) = PCompanyHelper::getSyncStatus('fetchjobs', $thirdaccount_status_jiancai,true);
             ?>
               <a href="#accountsetdialog_jiancai" class="ppp_bluebtn btn_click" data-type='jiancai' data-syncaction='fetchjobs' data-autofetchon="<?=$autofetchjobs_on_jiancai ?>" data-vid="<?=$_['masteruser']?$user->vid:0  ?>" id='sync_click_jiancai'>同步职位</a>
               <i title="<?=$sync_jiancai_iclass ? $sync_jiancai_title : '尚未同步'?>" class="syc_iconsown <?=$sync_jiancai_iclass ? $sync_jiancai_iclass : 'syc_iconsown_gray'?>"></i>
            <?php else: ?>
               <span style="margin-left:-15px;" class="ppp_whitebtn btn_success">同步中...</span>
            <?php endif; ?>
            <?php endif;?>
            </td>

            <?php if($_['masteruser']):?>
            <td id="autofetchjobs_result_jiancai" data-loginstatus="<?=$login_status_jiancai ?>" data-synctype="jiancai" data-syncaction="autofetchjobs">
            <?php if($hasPermission):?>
             <?php if(!($autofetchjobs_info_jiancai === NULL) && $check_syncstatus_jiancai):?> 
                <?php if(!isset($autofetchjobs_info_jiancai['disabled']) || $autofetchjobs_info_jiancai['disabled'] == 1):?>
                   <span  class="hdbtn hdbtn_notok" title="点击开启自动同步"></span>
                   <i class="syc_iconsown syc_iconsown_gray"></i>
                <?php else: ?>
                   <span class="hdbtn hdbtn_ok"></span>
                   <?php if(isset($autofetchjobs_info_jiancai['result'])):?>
                      <?php if($autofetchjobs_info_jiancai['result'] == 'success'): ?>
                      <i class="syc_iconsown syc_iconsown_success" title="<?php echo JHtml::_('date', $autofetchjobs_info_jiancai['time'], 'Y-m-d H:i:s') .' '. (empty($autofetchjobs_info_jiancai['msg'])?'同步成功！':$autofetchjobs_info_jiancai['msg']); ?>"></i>
                      <?php elseif($autofetchjobs_info_jiancai['result'] == 'syncing'): ?>
                      <i class="syc_iconsown syc_iconsown_gray" title="自动同步中"></i>
                      <?php elseif($autofetchjobs_info_jiancai['result'] == 'error'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="<?=$autofetchjobs_info_jiancai['msg'] ?>"></i>
                      <?php elseif($autofetchjobs_info_jiancai['result'] == 'captcha'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="登录验证码失败！"></i>
                      <?php endif;?>
                  <?php else: ?>
                    <i class="syc_iconsown syc_iconsown_gray"></i>
                  <?php endif?>
                <?php endif; ?>
            <?php else: ?>
               <span  class="hdbtn hdbtn_notok" title="点击开启自动同步"></span>
               <i class="syc_iconsown syc_iconsown_gray"></i>
            <?php endif; ?>
            <?php endif; ?>

            </td>

            <td id="autorenewjobs_result_jiancai" data-loginstatus="<?=$login_status_jiancai ?>" data-synctype="jiancai" data-syncaction="autorenewjobs">
            <?php if($hasPermission):?>
              <?php if(!($autorenewjobs_info_jiancai === NULL) && $check_syncstatus_jiancai):?> 
                <?php if(!isset($autorenewjobs_info_jiancai['disabled']) || $autorenewjobs_info_jiancai['disabled'] == 1):?>
                   <span  class="hdbtn hdbtn_notok" title="点击开启自动刷新"></span>
                   <i class="syc_iconsown syc_iconsown_gray"></i>
                <?php else: ?>
                   <span class="hdbtn hdbtn_ok"></span>
                   <?php if(isset($autorenewjobs_info_jiancai['result'])):?>
                      <?php if($autorenewjobs_info_jiancai['result'] == 'success'): ?>
                      <i class="syc_iconsown syc_iconsown_success" title="<?php echo JHtml::_('date', $autorenewjobs_info_jiancai['time'], 'Y-m-d H:i:s') .' '. (empty($autorenewjobs_info_jiancai['msg'])?'刷新成功！':$autorenewjobs_info_jiancai['msg']); ?>"></i>
                      <?php elseif($autorenewjobs_info_jiancai['result'] == 'syncing'): ?>
                      <i class="syc_iconsown syc_iconsown_gray" title="自动刷新中"></i>
                      <?php elseif($autorenewjobs_info_jiancai['result'] == 'error'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="<?=$autorenewjobs_info_jiancai['msg'] ?>"></i>
                      <?php elseif($autorenewjobs_info_jiancai['result'] == 'captcha'): ?>
                      <i class="syc_iconsown syc_iconsown_fail" title="登录验证码失败！"></i>
                      <?php endif; ?>
                   <?php else:?>
                    <i class="syc_iconsown syc_iconsown_gray"></i>
                   <?php endif;?>
                <?php endif; ?>
            <?php else: ?>
               <span  class="hdbtn hdbtn_notok" title="点击开启自动刷新"></span>
               <i class="syc_iconsown syc_iconsown_gray"></i>
            <?php endif; ?>

            <?php 
               $selectjobtitle = "";
               if (!empty($autorenewfolderid_jiancai)) {
                  list($selectjobtitle,$curcityids,$curfolderid) = PCompanyHelper::getSelectJobTitle($autorenewfolderid_jiancai);
                  echo "<a id=\"selectjobtitle\" href=\"javascript:;\" class=\"ppp_whitebtn\">".$selectjobtitle."</a>";
               }
             ?>
             <?php endif; ?>

            </td>
            <?php endif; ?>
         </tr>
         
      </table>
   </div>
</div>

<div class="hr_net_tipdialog popup" id="hr_howtoconfig" style="width:260px; display:none; top:auto; left:auto;">
   <div class="hr_net_point"></div>
   <div class="closediv"></div>
	<div class="hr_net_tipcontent">
	   <p>1. 登录<a href="http://ehire.51job.com/MainLogin.aspx" target="_blank">前程无忧</a> / <a href="http://hr.zhaopin.com/hrclub/index.html" target="_blank">智联招聘</a> / <a href="http://ent.buildhr.com/login" target="_blank">建筑英才</a></p>
      <p>2. 进入已发布的职位详情页</p>
      <p class="clearfix"><em class="pull-left">3.</em> <em class="blockstyle">找到<b>简历接收方式</b>，填写云招聘邮箱<br/>地址 <b class="yellowcolor"><?php echo $_['resumeforwardemail']?></b></em></p>
      <p class="textright"><a target="_blank" href="<?=JURI::base()?>helps/doc/product/whatcloudforyou.html">查看详细帮助</a></p>
   </div>
</div>


<div class="hr_net_tipdialog popup accountsetdialog hr_accountchange" id="51job_accountchange" style="width:340px; display:none; top:auto; left:auto;">
   <div class="hr_net_point"></div>
   <div class="close"></div>
   <form id="51job_form" action="<?php echo OC_Helper::linkToRoute("company_savesyncaccount"); ?>" method="post">
	<div class="hr_net_tipcontent" style="padding:20px 15px;">
	   <div class="form-horizontal accountsetform">
	   <div class="formtip medium">请输入您在前程无忧的账号信息，仅用于数据同步</div>
        <div class="control-group">
          <label class="control-label key" for="inputEmail">会员名:</label>
          <div class="controls">
            <input type="text" name="account_membername" class="required" value="<?php echo (isset($thirdaccount_51job['membername']) ? $thirdaccount_51job['membername']: '');?>">
          </div>
        </div>
        <div class="control-group">
          <label class="control-label key" for="inputPassword">用户名:</label>
          <div class="controls">
            <input type="text" name="account_username"  class="required" value="<?php echo (isset($thirdaccount_51job['username']) ? $thirdaccount_51job['username']: '');?>">
          </div>
        </div>
        <div class="control-group" style="margin-bottom:5px;">
          <label class="control-label key" for="inputPassword">密码:</label>
          <div class="controls">
            <input type="password" name="account_password" autocomplete="off" maxlength="12" minlength="6" class="required" value="<?php echo (!empty($thirdaccount_51job['password'])? str_repeat('*', $thirdaccount_51job['passwordlen']) : '');?>">
          </div>
        </div>
        <div class="control-group" style="margin-bottom:0px;">
          <div class="controls change_confirm">
            <label class="checkbox medium gray">
              <input type="checkbox" <?php echo (!empty($thirdaccount_51job) && empty($thirdaccount_51job['password']) ? '' : 'checked="checked"');?> name="rememberme" value="1"> 记住密码<em style="color:#999999;">（以后不需要再输入账号密码）</em>
            </label>
            <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
            <input type="hidden" name="type" value="51job">
            <input type="submit" class="ppp_bluebtn btn medium " value="确认" style="margin-top:5px;"/>
            <span style="display:none" class="error systemerror"></span>
          </div>
        </div>
      </div>
   </div>
</form>
</div>

<div class="hr_net_tipdialog popup accountsetdialog hr_accountchange" id="zhilian_accountchange" style="width:340px; display:none; top:auto; left:auto;">
   <div class="hr_net_point"></div>
   <div class="close"></div>
   <form id="zhilian_form" action="<?php echo OC_Helper::linkToRoute("company_savesyncaccount"); ?>" method="post">
	<div class="hr_net_tipcontent" style="padding:20px 15px;">
	   <div class="form-horizontal accountsetform">
	   <div class="formtip medium">请输入您在智联招聘的账号信息，仅用于数据同步</div>
        <div class="control-group">
          <label class="control-label key" for="inputPassword">用户名:</label>
          <div class="controls">
            <input type="text" name="account_username" class="required" value="<?php echo (isset($thirdaccount_zhilian['username']) ? $thirdaccount_zhilian['username']: '');?>">
          </div>
        </div>
        <div class="control-group" style="margin-bottom:5px;">
          <label class="control-label key" for="inputPassword">密码:</label>
          <div class="controls">
            <input type="password" name="account_password" autocomplete="off" maxlength="40" minlength="8" class="required" value="<?php echo (!empty($thirdaccount_zhilian['password'])? str_repeat('*', $thirdaccount_zhilian['passwordlen']): '');?>">
          </div>
        </div>
        <div class="control-group" style="margin-bottom:0px;">
          <div class="controls change_confirm">
            <label class="checkbox medium gray">
              <input type="checkbox" <?php echo (!empty($thirdaccount_zhilian) && empty($thirdaccount_zhilian['password']) ? '' : 'checked="checked"');?> name="rememberme" value="1"> 记住密码<em style="color:#999999;">（以后不需要再输入账号密码）</em>
            </label>
            <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
            <input type="hidden" name="type" value="zhilian">
            <input type="submit" class="ppp_bluebtn btn medium" value="确认" style="margin-top:5px;"/>
            <span style="display:none" class="error systemerror"></span>
          </div>
        </div>
      </div>
   </div>
   </form>
</div>

<div class="hr_net_tipdialog popup accountsetdialog hr_accountchange" id="jiancai_accountchange" style="width:340px; display:none; top:auto; left:auto;">
   <div class="hr_net_point"></div>
   <div class="close"></div>
   <form id="jiancai_form" action="<?php echo OC_Helper::linkToRoute("company_savesyncaccount"); ?>" method="post">
   <div class="hr_net_tipcontent" style="padding:20px 15px;">
      <div class="form-horizontal accountsetform">
      <div class="formtip medium">请输入您在建筑英才的账号信息，仅用于数据同步</div>
        <div class="control-group">
          <label class="control-label key" for="inputPassword">用户名:</label>
          <div class="controls">
            <input type="text" name="account_username" class="required" value="<?php echo (isset($thirdaccount_jiancai['username']) ? $thirdaccount_jiancai['username']: '');?>">
          </div>
        </div>
        <div class="control-group" style="margin-bottom:5px;">
          <label class="control-label key" for="inputPassword">密码:</label>
          <div class="controls">
            <input type="password" name="account_password" autocomplete="off" maxlength="25" minlength="6" class="required" value="<?php echo (!empty($thirdaccount_jiancai['password'])? str_repeat('*', $thirdaccount_jiancai['passwordlen']): '');?>">
          </div>
        </div>
        <div class="control-group" style="margin-bottom:0px;">
          <div class="controls change_confirm">
            <label class="checkbox medium gray">
              <input type="checkbox" <?php echo (!empty($thirdaccount_jiancai) && empty($thirdaccount_jiancai['password']) ? '' : 'checked="checked"');?> name="rememberme" value="1"> 记住密码<em style="color:#999999;">（以后不需要再输入账号密码）</em>
            </label>
            <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
            <input type="hidden" name="type" value="jiancai">
            <input type="submit" class="ppp_bluebtn btn medium" value="确认" style="margin-top:5px;"/>
            <span style="display:none" class="error systemerror"></span>
          </div>
        </div>
      </div>
   </div>
   </form>
</div>
<div class="hr_net_tipdialog popup accountsetdialog hr_accountchange" id="lagou_accountchange" style="width:340px; display:none; top:auto; left:auto;">
   <div class="hr_net_point"></div>
   <div class="close"></div>
   <form id="lagou_form" action="<?php echo OC_Helper::linkToRoute("company_savesyncaccount"); ?>" method="post">
   <div class="hr_net_tipcontent" style="padding:20px 15px;">
      <div class="form-horizontal accountsetform">
      <div class="formtip medium">请输入您在拉勾的账号信息，仅用于数据同步</div>
        <div class="control-group">
          <label class="control-label key" for="inputPassword">用户名:</label>
          <div class="controls">
            <input type="text" name="account_username" class="required" value="<?php echo (isset($thirdaccount_lagou['username']) ? $thirdaccount_lagou['username']: '');?>">
          </div>
        </div>
        <div class="control-group" style="margin-bottom:5px;">
          <label class="control-label key" for="inputPassword">密码:</label>
          <div class="controls">
            <input type="password" name="account_password" autocomplete="off" maxlength="25" minlength="6" class="required" value="<?php echo (!empty($thirdaccount_lagou['password'])? str_repeat('*', $thirdaccount_lagou['passwordlen']): '');?>">
          </div>
        </div>
        <div class="control-group" style="margin-bottom:0px;">
          <div class="controls change_confirm">
            <label class="checkbox medium gray">
              <input type="checkbox" <?php echo (!empty($thirdaccount_lagou) && empty($thirdaccount_lagou['password']) ? '' : 'checked="checked"');?> name="rememberme" value="1"> 记住密码<em style="color:#999999;">（以后不需要再输入账号密码）</em>
            </label>
            <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
            <input type="hidden" name="type" value="lagou">
            <input type="submit" class="ppp_bluebtn btn medium" value="确认" style="margin-top:5px;"/>
            <span style="display:none" class="error systemerror"></span>
          </div>
        </div>
      </div>
   </div>
   </form>
</div>

<!-- 企业中心自动同步确认dialog -->
<div class="modal hide fade autorenew_dialog" id="autofetchjobs">
</div>
<div class="modal hide fade autorenew_dialog" id="autofetchjobs_successdialog">  
</div>

<!-- 自动刷新选择职位组合dialog -->
<div style="position: absolute;" class="modal hide fade autorn_posdialog" id="positionselect">
</div>

<!-- Modal 51job -->
<div id="accountsetdialog_51job" class="modal hide fade accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<!-- Modal zhilian -->
<div id="accountsetdialog_zhilian" class="modal hide fade accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<!-- Modal jianzuyingcai -->
<div id="accountsetdialog_jiancai" class="modal hide fade accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<!-- Modal lagou -->
<div id="accountsetdialog_lagou" class="modal hide fade accountsetdialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
